package edu.ues21.tcs.ecommerce2011.mvc.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import edu.ues21.tcs.ecommerce2011.mvc.dao.MarcaDAO;
import edu.ues21.tcs.ecommerce2011.mvc.model.Marca;

/**
 * 
 * @author Acunia Marco.
 */
public class ListarMarcaAdminController extends HttpServlet {

	ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
			"/BeanLocations.xml");

	MarcaDAO mDao = (MarcaDAO) appContext.getBean("marcaDAO");

	private static final long serialVersionUID = 1L;

	
	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		List<Marca> listaM = mDao.getAll();

		request.setAttribute("Marcas", listaM);
		request.getRequestDispatcher("view/CRUDMarcas.jsp").forward(request,
				response);

	}

	
	@Override
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	
	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	
	@Override
	public String getServletInfo() {
		return "Short description";
	}// </editor-fold>

}
